#ifndef GAMETD_PLAYERMANAGER_H
#define GAMETD_PLAYERMANAGER_H

#include <SDL.h>
#include "Manager.h"
#include "Vector2.h"
#include "Animation.h"
#include "Face.h"

class PlayerManager : public Manager<PlayerManager> {
    friend class Manager<PlayerManager>;

public:
    void OnInput(const SDL_Event &event);
    void OnUpdate(double delta);
    void OnRender(SDL_Renderer *renderer);
    double GetCurrentMp() const;

protected:
    PlayerManager();
    ~PlayerManager() = default;

private:
    void OnReleaseFlash();
    void OnReleaseImpact();

private:
    Vector2 size;
    Vector2 position;
    Vector2 velocity;

    SDL_Rect rectHitboxFlash = {0};
    SDL_Rect rectHitboxImpact = {0};

    double mp = 100;
    double speed = 0;

    bool canReleaseFlash = true;
    bool isReleasingFlash = false;
    bool isReleasingImpact = false;
    bool isMoveUp = false;
    bool isMoveDown = false;
    bool isMoveLeft = false;
    bool isMoveRight = false;

    Animation anim_idle_up;
    Animation anim_idle_down;
    Animation anim_idle_left;
    Animation animIdleRight;
    Animation animAttackUp;
    Animation animAttackDown;
    Animation animAttackLeft;
    Animation animAttackRight;
    Animation *animCurrent = &animIdleRight;

    Animation animEffectFlashUp;
    Animation animEffectFlashDown;
    Animation animEffectFlashLeft;
    Animation animEffectFlashRight;
    Animation *animEffectFlashCurrent = nullptr;

    Animation animEffectImpactUp;
    Animation animEffectImpactDown;
    Animation animEffectImpactLeft;
    Animation animEffectImpactRight;
    Animation *animEffectImpactCurrent = nullptr;

    Timer timerReleaseFlashCd;
    Timer timerAutoIncreaseMp;
    Facing facing = Facing::Left;
};


#endif //GAMETD_PLAYERMANAGER_H
